var mysql   = require('mysql');
var exports=module.exports;

    exports.select=function(sql, callback){
	var mysqlConnection = mysql.createConnection({
	  host     : 'localhost',
	  user     : 'root',
	  password : 'root',
	  database : 'blogs',
	  port: '3306',
	});
	mysqlConnection.connect(function(){
		//console.log('mysql链接成功！')
	});
	mysqlConnection.query(sql,function(err,result){
		console.log("-----------------sql-------------------");
		console.log(sql);
		console.log("-----------------sql-------------------");
        if(err){
			console.log('[错误] --- ',err.message);
			return;
		}
        // console.log(result)
        callback(result)    //此处callback就是将值取出来
    	});
	setTimeout(()=>{
		mysqlConnection.end();
	},2000);
    };
